<?php

namespace Extension;



class ManagerRequest {
	private $m_Url = "http://127.0.0.1:1007/";
	/**
	 * 构造函数
	 */
	function __construct() {
	}
	/**
	 * 析构函数
	 */
	function __destruct() {
	}
	/**
	 * 发送POST数据
	 *
	 * @param unknown $url        	
	 * @param unknown $post_data        	
	 * @return string
	 */
	public static function mb_SendPost($url, $post_data) {
		$postdata = http_build_query ( $post_data );
		$options = array (
				'http' => array (
						'method' => 'POST',
						'header' => 'Content-type:application/x-www-form-urlencoded',
						'content' => $postdata,
						'timeout' => 15 * 60  // 超时时间（单位:s）
				) 
		);
		$context = stream_context_create ( $options );
		$result = file_get_contents ( $url, false, $context );
		return $result;
	}
	/**
	 *
	 * @return string
	 */
	public function mb_TestConnect() {
// 		$data = new \stdClass ();
// 		$data->name = 'user1';
// 		$data->pass = '000001';
		
// 		$pData = array ();
// 		$pData ['m_Data'] = json_encode ( $data );
// 		$pData ['m_Sign'] = md5 ( $pData['m_Data'] . Cfg::MSG_MD5 );
		
// 		return self::mb_SendPost ( $this->m_Url . 'mb_TestConnect', array (
// 				'data' => json_encode ( $pData ) 
// 		) );
	
		
	}
	
	/**
	 * 账号注册
	 *
	 * @param unknown $account        	
	 * @param unknown $nick        	
	 * @param unknown $password        	
	 * @return unknown
	 */
	function AccountRegist($account, $nick, $password, $agent, $phone) {
		$arr = new ReqParam ();
		$arr->req = '1';
		$arr->account = $account;
		$arr->nick = $nick;
		$arr->password = $password;
		$arr->agentname = $agent;
		$arr->phone = $phone;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
}